package com.ppx.controller;

import com.alibaba.fastjson.JSONObject;
import com.ppx.pojo.Info;
import com.ppx.service.InfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author wangxiaotao
 * @create 2021-05-24-8:46
 */
@Controller
@RequestMapping("/info")
public class InfoController {
	@Autowired
	private InfoService infoService;

	//统计人数
	@RequestMapping("/confirmCount")
	@ResponseBody
	public int confirmCount(){
		return infoService.confirmCount();
	}

	//查询出所有省份
	@RequestMapping("/queryAllProvinceName")
	@ResponseBody
	public List<String> queryAllProvinceName(){
		return infoService.queryAllProvinceName();
	}

	//根据省份查询出该省份的疫情信息
	@RequestMapping("/queryEpidemicByProvinceName")
	@ResponseBody
	public List<Map<String ,Object>> queryEpidemicByProvinceName(String provinceName){
		return infoService.queryEpidemicByProvinceName(provinceName);
	}

	//根据省份查询出该省份的人数前五的地区
	@RequestMapping("/queryTopFiveConfrimByName")
	@ResponseBody
	public List<String[]> queryTopFiveConfrimByName(String provinceName){
		return infoService.queryTopFiveConfrimByName(provinceName);
	}

	//根据省份查询出该省份的治愈人数前五的地区
	@RequestMapping("/queryCuredCountByName")
	@ResponseBody
	public List<String[]> queryCuredCountByName(String provinceName){
		return infoService.queryCuredCountByName(provinceName);
	}

	//根据省份查询出该省份的死亡人数前五的地区
	@RequestMapping("/queryDeadCountByName")
	@ResponseBody
	public List<Map<String, Object>> queryDeadCountByName(String provinceName){
		return infoService.queryDeadCountByName(provinceName);
	}

	//查询所有人数
	@RequestMapping("/queryAllCount")
	@ResponseBody
	public List<Map<String, Object>> queryAllCount(){
		return infoService.queryAllCount();
	}

	//按省份查询所有感染人数
	@RequestMapping("/queryConfirmCount")
	@ResponseBody
	public List<Map<String,Object>>queryConfirmCount( ){
		return infoService.queryConfirmCount();
	}

	//查询所有info信息
	@RequestMapping("/queryAllInfo")
	@ResponseBody
	public HashMap<String,Object> queryAllInfo(int page,int limit){
		return infoService.queryAllInfo(page,limit);
	}

	//修改info数据
	@RequestMapping("/updataInfoById")
	@ResponseBody
	public String updataInfoById(Integer id,String dataType,Integer data){
		return JSONObject.toJSONString(infoService.updataInfoById(dataType,data,id));
	}

	//根据省份查询该省份的所有info数据
	@RequestMapping("/queryAllInfoByProvinceName")
	@ResponseBody
	public HashMap<String, Object> queryAllInfoByProvinceName(int page,int limit,String ProvinceName){
		return infoService.queryAllInfoByProvinceName(page,limit,ProvinceName);
	}

	//点击地图查看的某省数据
	@RequestMapping("/queryEpidemicAreaMapByCity")
	@ResponseBody
	public List<Map<String,Object>> queryEpidemicAreaMapByCity(String provinceName){
		return infoService.queryEpidemicAreaMapByCity(provinceName);
	}

}


